package org.whatever.aha.zjut.platform.controller.competition;

import cn.dev33.satoken.annotation.SaCheckRole;
import cn.dev33.satoken.annotation.SaMode;
import io.swagger.annotations.*;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.whatever.aha.zjut.base.constant.AuthConst;
import org.whatever.aha.zjut.base.dto.AjaxResult;
import org.whatever.aha.zjut.platform.dto.competition.AcademyCompetitionDto;
import org.whatever.aha.zjut.platform.dto.competition.CompetitionDetailDto;
import org.whatever.aha.zjut.platform.service.competition.AcademyCompetitionService;
import org.whatever.aha.zjut.platform.vo.competition.AcademyCompetitionVo;

import java.util.List;

/**
 * @author Vc
 * @version 1.0
 * @Desc
 * @date 2021/09/10 23:54
 */
@Api(tags = "学院赛事相关操作类")
@RequestMapping("/v1/academyCompetition")
@RequiredArgsConstructor
@RestController
@Validated
public class AcademyCompetitionController {
    final AcademyCompetitionService academyCompetitionService;


    /**
     *  创建新的学院比赛信息
     *
     * @param stageId
     * @param academyCompetitionListDto
     * @return
     */
    @SaCheckRole(value = {AuthConst.R_supper, AuthConst.R_school}, mode = SaMode.OR)
    @ApiOperation("创建新的学院比赛信息")
    @PostMapping("/createAcademyCompetition")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "stageId", value = "阶段id", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "academyCompetitionDto", value = "学院竞赛详细信息", dataTypeClass = AcademyCompetitionDto.class)
    })
    public AjaxResult<Integer> createCompetition(@ApiParam(value = "阶段id",required = true) int stageId, @ApiParam(value = "学院竞赛详细信息",required = true) @RequestBody @Validated List<AcademyCompetitionDto> academyCompetitionListDto) {
        return AjaxResult.SUCCESS(academyCompetitionService.addAcademyCompByList(stageId, academyCompetitionListDto));
    }

    /**
     *  获取新的学院比赛信息
     *
     * @param stageId
     * @param academyId
     * @return
     */
    @SaCheckRole(value = {AuthConst.R_supper, AuthConst.R_school, AuthConst.R_academy}, mode = SaMode.OR)
    @ApiOperation("获取学院比赛信息")
    @GetMapping("/getAcademyCompetition/{stageId}/{academyId}")
    public AjaxResult<AcademyCompetitionVo> getAcademyCompetition(@PathVariable("stageId") int stageId,
                                                                  @PathVariable("academyId") int academyId) {
        return AjaxResult.SUCCESS(academyCompetitionService.getAcademyCompetitionVoById(academyId, stageId));
    }


}
